﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.BL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;
using System.Data;

namespace GNCMedia.KQXS.UserControls
{
    public partial class TintucController : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                BreakingNewsBL breakingBl = new BreakingNewsBL();
                List<BreakingNewsDO> allDataSport = new List<BreakingNewsDO>();
                allDataSport = breakingBl.SelectAll();
                int rowncont = 0;
                DataTable dt = breakingBl.selectAll_groupnews(1, 1, 3, ref rowncont);
                foreach (DataRow item in dt.Rows)
                {
                    Image_tinthethao1.ImageUrl = item["IMAGE"].ToString();
                    Image_tinthethao1.Height = 20;
                    Image_tinthethao1.Width = 20;
                    string reques = "<a href='DetailNews.aspx?ID=" + item["NEWSID"]+ "'><font color='blue'>Xem thêm</font></a>";
                    byte[] allcontent = (byte[])item["NEWSCONTENT"];
                    string content = System.Text.UTF8Encoding.UTF8.GetString(allcontent);
                    if (content.Length > 450)
                    {
                        lb_tinthethao1.Text = content.ToString().Substring(0, 250) + "..." + reques;
                    }
                    else
                    {
                        lb_tinthethao1.Text = content.ToString() + "..." + reques;

                    }
                }



            }
            catch (Exception ex)
            {
                Response.Write("lỗi laoi tin tuc thể thao :" + ex);
            }
            finally
            {

            }
        }
    }
}